﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Stopwatch {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
            this.stopWatchCtl1.StopStopwatch();
        }

        private void menuItemStart_Click(object sender, EventArgs e) {
            if (this.stopWatchCtl1.Running) {
                this.stopWatchCtl1.StopStopwatch();
            } else {
                this.stopWatchCtl1.StartStopwatch();
            }
        }

        private void menuItem1_Click(object sender, EventArgs e) {
            this.stopWatchCtl1.Laptime();
        }

        public void RepresentState() {
            if (this.stopWatchCtl1.Running) {
                this.menuItemStart.Text = "Stop";
                this.menuItemLap.Enabled = true;
            } else {
                this.menuItemStart.Text = "Start";
                this.menuItemLap.Enabled = false;
            }
        }

        private void stopWatchCtl1_StateChanged(object sender, EventArgs e) {
            this.RepresentState();
        }

        private void Form1_Deactivate(object sender, EventArgs e) {
            this.stopWatchCtl1.SlowScreenUpdate();
        }

        private void Form1_Activated(object sender, EventArgs e) {
            this.stopWatchCtl1.FastScreenUpdate();
        }
    }
}